var config = require('../config');
var mongoose = require('mongoose');
var moment = require('moment');

//var setting = require('./models/setting');

//mongoose
var url = 'mongodb://' + config.host + '/' + config.db;
mongoose.connect(url, {
 user : config.user,
 pass : config.pwd
});

require('../models/user.js');
require('../models/category.js');

var User = mongoose.model('User');
var Category = mongoose.model('Category');

var parent = new Category({
  text: '测试题目分类',
  leaf : false
});

parent.save(function(err, doc){
  for(var i = 0 ; i < 5; i++){
    var child = new Category({
      text : '子项分类_' + i,
      leaf : true
    });
    child.parent = parent;
    child.save(function(err, doc){
      console.log(doc);
    });
  }
});


